package biz

import (
	"context"
	"github.com/go-kratos/kratos/v2/log"
	"gorm.io/gorm"
	"phm/models/generator/model"
)

type TimedTaskFaultResultRepo interface {
	CreateTimedTaskFaultResult(ctx context.Context, uModel *model.TimedTaskFaultResult, db *gorm.DB) error
	UpdateTimedTaskFaultResult(ctx context.Context, uModel *model.TimedTaskFaultResult, db *gorm.DB) error
	DeleteTimedTaskFaultResultByIds(ctx context.Context, ids []string, db *gorm.DB) error
	GetTimedTaskFaultResultById(ctx context.Context, id string) (*model.TimedTaskFaultResult, error)
	GetTimedTaskFaultResultByIds(ctx context.Context, ids []string) ([]*model.TimedTaskFaultResult, error)
	GetTimedTaskFaultResultList(ctx context.Context, query string, pageNum, pageSize int64) ([]*model.TimedTaskFaultResult, int64, error)
	// GetTimedTaskFaultResultByRadarIdList 通过雷达id获取计算结果：
	GetTimedTaskFaultResultByRadarIdList(ctx context.Context, idList []string) (map[string]*RadarFaultResult, error)
	// GetDB 得到db以方便事务处理
	GetDB() *gorm.DB
}

type RadarFaultResult struct {
	// radar id
	RadarId string `gorm:"column:radar_id"`
	// non-switch-low
	NonSwitchLow *int64 `gorm:"column:non_switch_low" json:"non_switch_low"`
	// non-switch-fault
	NonSwitchFault *int64 `gorm:"column:non_switch_fault" json:"non_switch_fault"`
	// switch-fault
	SwitchFault *int64 `gorm:"column:switch_fault" json:"switch_fault"`
}

type TimedTaskFaultResultUseCase struct {
	timedTaskFaultResult TimedTaskFaultResultRepo
	log                  *log.Helper
}

func NewTimedTaskFaultResultUseCase(timedTaskFaultResult TimedTaskFaultResultRepo, logger log.Logger) *TimedTaskFaultResultUseCase {
	return &TimedTaskFaultResultUseCase{
		timedTaskFaultResult: timedTaskFaultResult,
		log:                  log.NewHelper(logger),
	}
}
